﻿using System;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using System.Drawing;

using Close.Controls;
using Close.Properties;
using Close.Classes;

namespace Close
{
    class LevelsPanel : FluidPanel
    {
        private FluidHeader header = new FluidHeader();
        private LevelListBox listBox = new LevelListBox();
        ThemeClass themeClass = ThemeClass.Settings;

        protected override void InitControl()
        {
            base.InitControl();
            //Bounds = new Rectangle(0, 0, 240, 300);
            BackColor = Color.Black;
            Anchor = AnchorAll;
            const int h = 32;
            header.Bounds = new Rectangle(0, 0, themeClass.DisplayWidth, h);
            listBox.Bounds = new Rectangle(0, h, themeClass.DisplayWidth, themeClass.DisplayHeight - h);
            header.Anchor = AnchorTLR;
            listBox.Anchor = AnchorAll;
            /*
            header.BackButton.Shape = ButtonShape.Rounded;
            header.BackButton.Visible = true;
            header.BackButton.Text = "OK";
            header.BackButton.Visible = false;
            */
            header.Title = Resources.DifTitle;
            //header.BackButton.Click += new EventHandler(BackButton_Click);

            Data.GameDatabase data = Data.GameDatabase.GamesData;
            listBox.DataSource = data.GetLevels();

            listBox.ItemClick +=new EventHandler<ListBoxItemEventArgs>(listBox_ItemClick); 

            Controls.Add(header);
            Controls.Add(listBox);
        }



        void BackButton_Click(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Occurs when an item was clicked.
        /// </summary>
        public event EventHandler<ListBoxItemEventArgs> ItemClick;
        void listBox_ItemClick(object sender, ListBoxItemEventArgs e)
        {
            if (ItemClick != null)
            {
                ItemClick(this, e);
            }
        }

        public LevelListBoxItem SelectedItem
        {
            get
            {
                return listBox.Item;
            }
        }
        public int SelectedIndex
        {
            get
            {
                return listBox.SelectedItemIndex;
            }
        }
        
        /*
        public List<LevelListBoxItem> Categories { get { return listBox.Categories; } }

        void BackButton_Click(object sender, EventArgs e)
        {
            ListBuilder.Instance.AddCategories(Categories);
            Close();
        }

        private static LevelsPanel instance;

        public static LevelsPanel Instance
        {
            get
            {
                if (instance == null) instance = new LevelsPanel();
                return instance;
            }
        }


        public override void Focus()
        {
            listBox.Focus();
        }


        internal void UpdateData()
        {
            listBox.UpdateData();
        }
         **/

    }
}
